package com.demo.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.demo.core.domain.Result;
import com.demo.domain.Reply;
import com.demo.core.exception.ParameterException;
import com.demo.domain.ro.SaveReRequest;
import com.demo.domain.vo.ReplyView;
import org.springframework.transaction.annotation.Transactional;

import java.io.IOException;
import java.util.List;

@Transactional
public interface ReplyService extends IService<Reply> {
//    IPage<Reply> getReplyByRcid(int currentPage, int pageSize,Reply reply);

    /**
     * 获取所有评论
     * @param currentPage
     * @param reply
     * @return
     */
    List<ReplyView> getReplyWithoutPage(int currentPage, Reply reply,Long uid) throws ParameterException;

    Result saveReply(SaveReRequest saveReRequest,Long uid) throws IOException, ParameterException;

    /**
     * 发布评论
     * @param reply
     * @return
     */
    boolean saveReplyFlag(Reply reply) throws ParameterException;

    /**
     * 获取当前用户被回复的评论及回复内容
     *
     * @param toUid
     * @return
     * @throws ParameterException
     */
    List<ReplyView> getReplyByToUid(long toUid)throws ParameterException;

    /**
     * 是否有未读的回复
     * @param uid
     * @return null-当前数据库无此uid的账户；true-有未读回复；false-无未读回复
     */
    public Boolean hasNotViewedReplies(Long uid) throws ParameterException;

    /**
     * 更改用户的回复信息都为已查看的状态
     * @param uid
     * @return null-当前数据库无此uid的账户；1-修改成功；0-修改失败
     * @throws ParameterException
     * @throws Exception
     */
    public Integer updateViewedReplies(Long uid);

    /**
     * 得到所有回复，有分页
     *
     * @param current
     * @param size
     * @return Page类型
     */
//    public Page<Reply> getReplyByPage(int current, int size) throws ParameterException;

    public Page<Reply> getRepliesByUser(Long toUid, int current, int size) throws ParameterException;
}
